package io;
import io.InputUtil.InputField;

import java.io.Serializable;

/**
 * 使用当前类学习对象序列化和反序列化
 */
public class Person implements Serializable {
    @InputField(title="名字",notNull=true)
    private String name;//名字
    @InputField(title="性别",notNull=true,regex="[男女]",regexNotMathTitle="性别只能是:【男】或【女】" )
    private char gender;//性别
    @InputField(title="年龄",notNull=true)
    private int age;//年龄
    /*
        transient:瞬间的
        当一个属性被transient关键字修饰后，那么该对象序列化时会忽略这个属性的值
        忽略不必要的属性可以到达对象序列化瘦身的目的。
     */
    @InputField(title="工资",notNull=true)
    private transient double salary;//工资
    @InputField(title="其他信息",notNull=true)
    private transient String otherInfo;//其他信息
    public Person(){}

    public Person(String name, char gender, int age, double salary, String otherInfo) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.salary = salary;
        this.otherInfo = otherInfo;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public char getGender() {
        return gender;
    }

    public void setGender(char gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public double getSalary() {
        return salary;
    }

    public void setSalary(double salary) {
        this.salary = salary;
    }

    public String getOtherInfo() {
        return otherInfo;
    }

    public void setOtherInfo(String otherInfo) {
        this.otherInfo = otherInfo;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", gender=" + gender +
                ", age=" + age +
                ", salary=" + salary +
                ", otherInfo='" + otherInfo + '\'' +
                '}';
    }
}
